package com.zmx.job.admin.repository;

import com.zmx.job.admin.entity.MallJobInfo;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
@author zhaomxr
*/
public interface MallJobInfoRepository extends BaseRepository<MallJobInfo>{

    /**
     * 根据 执行器任务handler 查询当前任务是否已存在
     * @param name 任务handler名称
     * @return
     */
    MallJobInfo findByExecutorHandler(String name);

    /**
     *
     * @param maxNextTime
     * @param pagesize
     * @return
     */
    @Query(value = "SELECT * FROM mall_job_info AS t WHERE t.trigger_status = 1 and t.trigger_next_time <= ?1 ORDER BY id ASC LIMIT ?2", nativeQuery = true)
    public List<MallJobInfo> scheduleJobQuery(long maxNextTime, int pagesize);
}
